package com.qf.administration.controller;

import com.github.pagehelper.PageInfo;
import com.qf.administration.qo.CarManageQO;
import com.qf.administration.service.CarManageService;
import com.qf.administration.vo.CarManageVO;
import com.qf.common.base.result.RespResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(tags = "车辆管理")
@RestController
@RequestMapping("/carmanage")
public class CarManageController {
    @Resource
    private CarManageService carManageService;

    @ApiOperation("添加车辆信息")
    @PostMapping("/add")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<String> addCarManage(@RequestBody CarManageQO carManageQO) {
        return carManageService.addCarManage(carManageQO);
    }

    @ApiOperation("伪删除车辆信息")
    @PutMapping("/delete")
    public RespResult<String> deleteCarManage(@RequestParam int[] ids) {
        return carManageService.deleteCarManage(ids);
    }

    @ApiOperation("修改车辆信息")
    @PutMapping("/update")
    public RespResult<String> updateCarManage(@RequestBody CarManageQO carManageQO) {
        return carManageService.updateCarManage(carManageQO);
    }

    @ApiOperation("查询车辆信息")
    @GetMapping("/list")
    public RespResult<PageInfo<CarManageVO>> queryCarManage(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size, @RequestParam(required = false) String busNumber, @RequestParam(required = false) String saddle, @RequestParam(required = false) String carSortName, @RequestParam(required = false) String carBrand, @RequestParam(required = false) String carStatus) {
        return RespResult.success(carManageService.queryCarManage(page, size, busNumber, saddle, carSortName, carBrand, carStatus));
    }

    @ApiOperation("查询车辆单条信息")
    @GetMapping("/one")
    public CarManageVO queryCarManageOne(@RequestParam int id) {
        return carManageService.queryCarManageOne(id);
    }
}
